package org.finesys.common.file.client.ftp;

import org.finesys.common.file.client.FileTemplate;
import org.finesys.common.file.properties.FileProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import lombok.AllArgsConstructor;

/**
 * FTP 文件上传
 */
@AllArgsConstructor
@Configuration
public class FtpAutoConfiguration {

    private final FileProperties fileProperties;

    @Bean
    @ConditionalOnMissingBean(FtpFileTemplate.class)
    @ConditionalOnProperty(value = "file.ftp.enable", havingValue = "true")
    FileTemplate ftpFileTemplate() {
        return new FtpFileTemplate(fileProperties);
    }
}
